/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ventanaInvitado.java
 *
 * Created on 25/06/2010, 12:06:11 PM
 */

package CapaGrafica;
import CapaLogica.ComunicaInvitado;
import CapaLogica.ComunicaReserva;
import javax.swing.JOptionPane;

/**
 *
 * @author Maria
 */
public class ventanaInvitado extends javax.swing.JFrame {

    /** Creates new form ventanaInvitado */
    public ventanaInvitado() {
        initComponents();
        this.setSize(500,500);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jBAgregar = new javax.swing.JButton();
        jBCancelar = new javax.swing.JButton();
        jTFNombreInvitado = new javax.swing.JTextField();
        jTFApellidoInvitado = new javax.swing.JTextField();
        jTFCedulaInvitado = new javax.swing.JTextField();
        jCBSexoInvitado = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        fechaNac = new datechooser.beans.DateChooserCombo();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel9 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Agrege sus acompanantes.");
        setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        setLocationByPlatform(true);

        jBAgregar.setText("Agregar");
        jBAgregar.setName("jBAgregar"); // NOI18N
        jBAgregar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBAgregarActionPerformed(evt);
            }
        });

        jBCancelar.setText("Cancelar");
        jBCancelar.setName("jBCancelar"); // NOI18N
        jBCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBCancelarActionPerformed(evt);
            }
        });

        jTFNombreInvitado.setName("jTFNombreInvitado"); // NOI18N

        jTFApellidoInvitado.setName("jTFApellidoInvitado"); // NOI18N

        jTFCedulaInvitado.setName("jTFCedulaInvitado"); // NOI18N

        jCBSexoInvitado.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "<Seleccione>", "Masculino", "Femenino" }));
        jCBSexoInvitado.setName("jCBSexoInvitado"); // NOI18N
        jCBSexoInvitado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCBSexoInvitadoActionPerformed(evt);
            }
        });

        jLabel1.setText("Nombre:");
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel2.setText("Apellido:");
        jLabel2.setName("jLabel2"); // NOI18N

        jLabel3.setName("jLabel3"); // NOI18N

        jLabel5.setText("Sexo:");
        jLabel5.setName("jLabel5"); // NOI18N

        jLabel6.setText("Cedula:");
        jLabel6.setName("jLabel6"); // NOI18N

        jLabel7.setText("Fecha Nacimiento:");
        jLabel7.setName("jLabel7"); // NOI18N

        jLabel8.setFont(new java.awt.Font("Trebuchet MS", 0, 36));
        jLabel8.setForeground(new java.awt.Color(0, 51, 204));
        jLabel8.setText("i-Resort.");
        jLabel8.setName("jLabel8"); // NOI18N

        jSeparator1.setName("jSeparator1"); // NOI18N

        jLabel9.setText("Registre a sus acompanantes:");
        jLabel9.setName("jLabel9"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 389, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 503, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 35, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(96, 96, 96)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel5)
                            .addComponent(jLabel7)
                            .addComponent(jLabel6)
                            .addComponent(jLabel2)
                            .addComponent(jLabel1)
                            .addComponent(jBAgregar))
                        .addGap(46, 46, 46)))
                .addGap(8, 8, 8)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jCBSexoInvitado, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jTFCedulaInvitado, javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jTFNombreInvitado, javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jTFApellidoInvitado, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 183, Short.MAX_VALUE)
                        .addComponent(fechaNac, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 144, Short.MAX_VALUE))
                    .addComponent(jBCancelar))
                .addContainerGap(82, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(158, 158, 158)
                .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(192, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(7, 7, 7)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jLabel9)
                .addGap(49, 49, 49)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel1)
                        .addGap(13, 13, 13)
                        .addComponent(jLabel2)
                        .addGap(12, 12, 12))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jTFNombreInvitado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jTFApellidoInvitado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(11, 11, 11)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel6)
                    .addComponent(jTFCedulaInvitado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jCBSexoInvitado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel7)
                    .addComponent(fechaNac, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 58, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jBCancelar)
                    .addComponent(jBAgregar))
                .addGap(36, 36, 36))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jBAgregarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBAgregarActionPerformed
      ComunicaReserva comunicameAReserva = new ComunicaReserva();
      ComunicaInvitado comunicameAInvitado = new ComunicaInvitado();

        if(comunicameAInvitado.validarInvitado(jTFNombreInvitado.getText(),jTFApellidoInvitado.getText(),jTFCedulaInvitado.getText(),fechaNac.getText(),jCBSexoInvitado.getSelectedIndex()))
        {
    if(comunicameAInvitado.agregarInvitado(jTFNombreInvitado.getText(),jTFApellidoInvitado.getText(),jTFCedulaInvitado.getText(),fechaNac.getText(),jCBSexoInvitado))
    {
        String options[] = {"Sí, Agregar", "No, Gracias"};//Respuestas

      int k = JOptionPane.showOptionDialog(null,"¿Desea Agregar Un Invitado Para Su Reserva ","",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,options,options[1]); // Numero de respuestas
      if (k==0)
         {
           ventanaInvitado elInvitado = new ventanaInvitado();
           elInvitado.setVisible(true);
         }
      else if (k==1)
         {
         ventanaPago elPago = new ventanaPago();
         double monto = comunicameAReserva.recibirMonto();
         elPago.setMonto(monto);
         elPago.setVisible(true);
      }

      this.dispose();
   }
        }  // TODO add your handling code here:
    }//GEN-LAST:event_jBAgregarActionPerformed

    private void jBCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBCancelarActionPerformed
       ComunicaReserva comunicameAReserva = new ComunicaReserva();
        String options[] = {" Sí, Cancelar Operación ", " No, Continuar "};//Respuestas

      int k = JOptionPane.showOptionDialog(null,"¿Esta Seguro Que Quiere Cancelar La Operación? ","",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,options,options[1]); // Numero de respuestas
      if (k==0)
         {
         ventanaPago elPago = new ventanaPago();
         double monto = comunicameAReserva.recibirMonto();
         elPago.setMonto(monto);
         elPago.setVisible(true);
         this.dispose();
         } // TODO add your handling code here:
    }//GEN-LAST:event_jBCancelarActionPerformed

    private void jCBSexoInvitadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCBSexoInvitadoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jCBSexoInvitadoActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new ventanaInvitado().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private datechooser.beans.DateChooserCombo fechaNac;
    private javax.swing.JButton jBAgregar;
    private javax.swing.JButton jBCancelar;
    private javax.swing.JComboBox jCBSexoInvitado;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTextField jTFApellidoInvitado;
    private javax.swing.JTextField jTFCedulaInvitado;
    private javax.swing.JTextField jTFNombreInvitado;
    // End of variables declaration//GEN-END:variables

}
